import { createRouter, createWebHistory } from 'vue-router'
import homeView from '@/views/home/home.vue'
import searchView from '@/views/search/index.vue'
import goodsView from '@/views/goods/index.vue'

import indexView from '@/views/home/children/index.vue'
import claView from '@/views/home/children/cla.vue'
import cartView from '@/views/home/children/cart.vue'
import faXianView from '@/views/home/children/faXian.vue'
import myView from '@/views/home/children/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/search',
      name: 'search',
      component: searchView,
    },
    {
      path: '/home',
      name: 'home',
      component: homeView,
      children: [
        {
          path: 'index',
          name: 'index',
          component: indexView,
        },
        {
          path: 'cla',
          name: 'cla',
          component: claView,
        },
        {
          path: 'faXian',
          name: 'faXian',
          component: faXianView,
        },
        {
          path: 'cart',
          name: 'cart',
          component: cartView,
        },
        {
          path: 'my',
          name: 'my',
          component: myView,
        },
      ]
    },
    {
      path: '/',
      redirect: '/home/index'
    },
    {
      path: '/goods/:query',
      name: 'goods',
      component: goodsView,
    }

  ],
})

export default router
